<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>初始化模块</title>
  </head>
  <body></body>
  <script>
    let module = (function() {
      //存放模块容器
      const moduleList = {};

      function define(name, modules, action) {
        //拿出模块
        modules.map((m, i) => {
          modules[i] = moduleList[m];
        });
        //压入模块
        moduleList[name] = action.apply(null, modules);
        // console.log(moduleList);
      }
      return { define };
    })();
    module.define("a", [], function() {
      return {
        site: "后盾人",
        url: "houdunren.com"
      };
    });
    module.define("b", ["a"], function(a) {
      a.site = "hdcms";
    });
    module.define("c", ["a"], function(a) {
      console.log(a);
    });
  </script>
</html>
